<?php

	include("bd/conexao/config.php"); // Arquivo de configuração MySQL

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>	Recuperar Senha </title>	

		<!-- ICON -->
		<link rel="icon" href="img/favicon-16.png" sizes="16x16">
		<link rel="icon" href="img/favicon-32.png" sizes="32x32">

		<!-- CSS -->	
		<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css">
		<link href="css/bootstrap-theme.min.css" rel="stylesheet" type="text/css">
		<link href="css/docs.min.css" rel="stylesheet" type="text/css">
		<link href="css/style.css" rel="stylesheet" type="text/css">
		<link href="http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,700italic,400,700,300&amp;subset=latin,cyrillic-ext,vietnamese,cyrillic" rel="stylesheet" type="text/css">

	    <!-- SCRIPTS -->
		<!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
		<script src="js/jquery.js"></script> 	
		<script src="js/jquery.validate.js"></script> 	
		
		<!-- Include all compiled plugins (below), or include individual files as needed -->
	    <script src="js/bootstrap.min.js"></script>

	    <script>   	  	

	    	 $(document).ready(function() {   	 
				
	    	 	/* Evento Botões */

    			$('#btnVoltar').click(function() {

					$(window.document.location).attr('href','login.php');

				});

	    		/* Validação Recupera Senha */

				$.validator.addMethod("valueNotEquals", function(value, element, arg){
  					return arg != value;
 				}, "Value must not equal arg.");		
				
				$('#form-recupera-senha').validate({

					rules:{

						txtLogin: { required: true }					

					},

					messages:{

						txtLogin: { required:  "Digite o login" }
					},

					submitHandler: function() { 

				   		var login = $('#login').val();
				   		
				   		$.post('scripts/recover-senha.php', 
				   		{
				   			txtLogin: login			   		

				   		}, function(resposta) {		   		

				        	var resultado = resposta;
				        	      	
				        	if (resultado != 0) {			        	    
				        		$('#alerta-senha').html('<strong>Senha: ' + resultado + '</strong>');
				        		$('#alerta-senha').show();	
			        		}

				        	else {				        		
				        		$('#alerta-senha').html('<strong> Usuário inexistente </strong>')
				        		$('#alerta-senha').show();		      	
			        	    }	       	
			        	   
				        });			       

				        return false;

				    }, 

					debug: true
			 
				});

				/* Limpar campo de resultado da pesquisa 
				   após perder foco no campo de login   */

				$('#login').blur(function() {
			       if ($(this).val() == "") {
			       		$('#alerta-senha').html('');	
			       		$('#alerta-senha').hide();

			       }

			    });

			});

		</script>

	</head>

	<body>

		<div class="container">           
				
				<div class="img-logo">

					<a href="http://www.grupoorguel.com.br" title="Grupo Orguel"> 
			      		<img src="img/logo_orguel.png" class="center-block" />
			    	</a>			

		    	</div>	 

		    	<div class="bs-callout bs-callout-danger" id="alerta-senha" style="display:none;">
						<!--<strong>Alerta!</strong> Usuário inexistente!! -->
				</div>   	 		
			   
				<form role="form" id="form-recupera-senha" class="senha" method="post">					
									    
				    <div class="control-group">

					    <div class="column">
					    	<input type="text" class="form-control" name="txtLogin" id="login" placeholder="Digite o login">							    
					    </div>

						<div class="column">
							<button type="submit" class="btn btn-primary" id="btnEnviar">Recupar Senha</button>
						</div>

						<div class="column">
							<button type="submit" class="btn btn-primary glyphicon glyphicon-home" id="btnVoltar"></button>
						</div>

					</div>

				</form>						

		</div>	

	</body>

</html>